<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../css/public.css">
</head>

<body>
    <!-- fillStyle 设置或返回用于填充绘画的颜色、渐变或模式-->
    <!-- getContext() 返回一个用于在画布上绘图的环境-->
    <!-- fillRect(x,y,width,height) 绘制“被填充”的矩形-->
    <!-- createRadialGradient(x0,y0,r0,x1,y1,r1) 创建放射状/圆形渐变对象-->
    <!-- addColorStop(stop,color) 规定渐变对象中的颜色和停止位置-->

    <canvas id="myCanvas2" width="300" height="150" style="border:1px solid #d3d3d3;"></canvas>


    <script>
        var b = document.getElementById('myCanvas2');
        var btx = b.getContext('2d');
        var b_gradient = btx.createRadialGradient(75, 50, 5, 90, 60, 100);
        b_gradient.addColorStop(0, "red");
        b_gradient.addColorStop(1, "white");
        btx.fillStyle = b_gradient;
        btx.fillRect(20, 20, 150, 100);
    </script>
</body>

</html>